// JavaScript Document
var _firstTypeId = null;
$(function(){
	var nav=$("<div class='nav'><div class='arrow'></div><div id='shopTypeLarge' class='bigNav'>"
			   +"<h2 onclick='chooseOperatyTypeAll()'>查看所有</h2><ul class='navlist'></ul></div>" +
			   	"<div class='smallNav'>"
			   +"<h3>店铺分类</h3>" +
			   	"<ul class='smList' id ='shopTypeSmall'>"
			   +"</ul>" +
			  "</div></div>");
	$("body").prepend(nav);	
		$(".bigNav,.smallNav").height($(document).height()-34);	
		
		$.ajax({
			url:'../operLargeType/find/all',
			type:'get',
			success:function(data){
			var dt = JSON.parse(data);
				if(dt.state==0){
					for ( var i = 0; i < dt.result.data.length; i++) {
						if(i==0){
							_firstTypeId = getHtmlString(getHeadIndexValue(i, dt, "id"));
						}
						var htm="<li  onclick='chooseShopSmallType("+ getHtmlString(getHeadIndexValue(i, dt, "id")) +",this)'><a href='javascript:void(0)'>"+ getHtmlString(getHeadIndexValue(i, dt, "name")) +"</a><span class='smbg'></span></li>";
						$("#shopTypeLarge ul").append(htm);
					}
			
				}
			}
		});
		
	$(".menuBtn").click(function(){
		if($(".nav").is(":visible")){
			$("body").css("overflow","auto");
			$(".nav").hide();
			$(".smallNav").hide();
		}else{
			$("body").css("overflow","hidden");
			chooseShopSmallType(_firstTypeId,null);
			$(".navlist li:first").addClass("focus").siblings().removeClass("focus");
			$(".nav").show();
			$(".smallNav").show();
		}
	});	//右侧悬浮菜单

});
	
 function  chooseShopSmallType(id,obj){
	if(IsNotEmpty(obj)){
		
	$(obj).addClass("focus").siblings().removeClass("focus");
	}
	$.ajax({
		url:'../operateType/find/ltId/'+id+'/0/100',
		type:'get',
		success:function(data){
		var dt = JSON.parse(data);
			if(dt.state==0){
				$("#shopTypeSmall").empty();
				for ( var i = 0; i < dt.result.data.length; i++) {
					var htm="<li  onclick='chooseOperateTypeID("+ getHtmlString(getHeadIndexValue(i, dt, "id")) +",this)'><a href='javascript:void(0)'>"+ getHtmlString(getHeadIndexValue(i, dt, "name")) +"</a><span class='smbg'></span></li>";
					$("#shopTypeSmall").append(htm);
				}
		
			}
		}
	});
}

function closeShopTypeChooseDiv(){
	$("body").css("overflow","auto");
	$(".nav").hide();
	$(".smallNav").hide();
}

